package com.atguigu.a_test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.ListIterator;
import java.util.Set;

/*
    HashMap中存ArrayList ->
        HashMap -> 学校集合<班级名称,班级集合> -> HashMap<String,ArrayList<Student>>
        ArrayList -> 班级集合<学生对象> -> ArrayList<Student>
 */
public class Demo1 {
    public static void main(String[] args) {
        //创建班级集合
        ArrayList<Student> basic = new ArrayList<>();
        basic.add(new Student("张三",18));
        basic.add(new Student("李四",18));
        basic.add(new Student("王五",18));
        ArrayList<Student> job = new ArrayList<>();
        job.add(new Student("赵六",19));
        job.add(new Student("田七",19));
        job.add(new Student("朱八",19));

        //创建学校集合
        HashMap<String, ArrayList<Student>> school = new HashMap<>();
        school.put("基础班",basic);
        school.put("就业班",job);

        //遍历
        Set<String> classNames = school.keySet();
        for (String className : classNames) {
            //根据班级名称获取班级集合
            ArrayList<Student> clazz = school.get(className);
            //遍历班级集合
            ListIterator<Student> lit = clazz.listIterator();
            while(lit.hasNext()){
                Student student = lit.next();
                //获取学生对象的信息
                String name = student.getName();
                int age = student.getAge();
                System.out.println("班级名称 : " + className + " , 学生姓名 : " + name + " , 学生年龄 : " + age);
            }
        }
    }
}
